Learn R Programming

vcfR (version 1.0.0)

Genotype matrix functions: Genotype matrix functions

Description

Functions which modify a matrix or vector of genotypes.

Usage

alleles2consensus(x, sep = "/", NA_to_n = TRUE)

get.alleles(x2, split = "/", na.rm = FALSE, as.numeric = FALSE)

Arguments

x
a matrix of alleles as genotypes (e.g., A/A, C/G, etc.)
sep
a character which delimits the alleles in a genotype (/ or |)
NA_to_n
logical indicating whether NAs should be scores as n
x2
a vector of genotypes
split
character passed to strsplit to split the genotype into alleles
na.rm
logical indicating whether to remove NAs
as.numeric
logical specifying whether to convert to a numeric

Details

The function alleles2consensus converts genotypes to a single consensus allele using IUPAC ambiguity codes for heterozygotes. Note that some functions, such as ape::seg.sites do not recognize ambiguity characters (other than 'n'). This means that these functions, as well as functions that depend on them (e.g., pegas::tajima.test), will produce unexpected results.

The function get.alleles takes a vector of genotypes and returns the unique alleles.